<script>
	
	$("#_uname").focus();
	
	$("#btnlogin").click(function() {
		enterme();
	});
	
	function enterme(){
			var uname = $("#_uname");
			var _pass = $("#_pass");
			
			if($("#uname").val() == "" || $("#uname").val() == " " ){
				alert("Enter your uname");
			}
			else if($("#_pass").val() == "" || $("#_pass").val() == " "  ){
				alert("Enter your password");
				
			}
			else{
				$.ajax ({
					url: "scripts/checker.php?uname="+uname.val() + "&pass="+_pass.val(),
					success: function(data){
					var split = data.split("+");
					//alert(split[1] + split[2]);
					
					
						if(split[0] == "1"){
											
							if(split[1] == 1){
							
								window.location.href = "scripts/set_session.php?id="+split[2];
								
							}
							else if(split[1] == 2){
								verification(split[2]);
							
							}
							else{
							
								if(confirm("Your account have been block please contact the Basci Autosales Admin")){
									localtion.reload();
								}
							}
								
								
						}
						else{
							alert("Username doesnt exist or wrong password");
							//$("#msgbox").html(data);
						}
					}	
				});
			}
		}
	
	
	
	function verification(codeid){
		
		$("#msgbox").load("include/verification.php?codeid="+codeid);
		$("#msgbox").dialog({
					modal:true,
					width:400,
					height:200,
					show: "fade",
					hide: "fade",
					resizeble:false,
					buttons: {
					},
				});	
	
	}


	
</script>
<div id="msgbox"></div>
<table>
<tr>
	<td>Username:</td>
	<td>
		<input type="text" id="_uname" name="" title="Input Username">
	</td>
</tr>

<tr>
	<td>Password:</td>
	<td>
		<input type="password" id="_pass" name="" title="Input Password">
	</td>
</tr>
<tr>
	<td>
		<button class="btnlogin" id="btnlogin">Login</button>
	</td>
	<td>
		<a href="forgot.php" id="">Forget Password</a>
	</td>
</tr>

</table>